import React from 'react'
import { Route, Redirect } from 'react-router-dom'
import { message } from 'antd';
const MenuRoute = ({ component: Component, ...props }) => {
    return <Route {...props} render={(p) => {
        let pname = p.match.path;
        let arrName = pname.split('/');
        let name = arrName[2];
        let menu = localStorage.menu || '';
        if (menu.indexOf(name) > -1) {
            return <Component {...p} />;
        } else {
            message.warning('没有该页面权限')
            return <Redirect to={{ pathname: '/main' }} />
        }
    }} />
}
export default MenuRoute;